package com.night.icm.service.base.mapper;

import com.night.icm.model.base.SystemDictionaryDTO;
import com.night.icm.persistence.base.entity.SystemDictionary;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.ReportingPolicy;

import java.util.List;

/**
 * DictionaryMapper
 *
 * @author Liao ZhiYong
 * @date 2019/12/22
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface DictionaryMapper {

    /**
     * 实体集合转为DTO集合
     *
     * @param entitys 实体集合
     * @return DTO集合
     */
    List<SystemDictionaryDTO> toList(List<SystemDictionary> entitys);

    /**
     * DTO转为实体
     *
     * @param systemDictionaryDTO dto
     * @return 实体
     */
    SystemDictionary toEntity(SystemDictionaryDTO systemDictionaryDTO);

    /**
     * 实体转为DTO
     *
     * @param systemDictionary 实体
     * @return DTO
     */
    SystemDictionaryDTO toDTO(SystemDictionary systemDictionary);

    /**
     * 更新一个已经存在的实体数据
     *
     * @param systemDictionaryDTO 存在的dto
     * @param systemDictionary    更新后的实体
     */
    void updateEntity(SystemDictionaryDTO systemDictionaryDTO, @MappingTarget SystemDictionary systemDictionary);
}
